﻿Imports System.Data.OleDb
Public Class frmImportar

    Private Sub frmImportar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'limpio el grid ATENCION y vuelvo a llenarlo
        mfgLLamadasAtencion.Clear()
        mfgLLamadasAtencion.Rows = 1
        TitulosGllam(mfgLLamadasAtencion)
        LeerBDimportados(mfgLLamadasAtencion)

        'limpio el grid VENTA y vuelvo a llenarlo
        mfgLlamadasVentas.Clear()
        mfgLlamadasVentas.Rows = 1
        TitulosGllamV(mfgLlamadasVentas)
        LeerBDimportadosV(mfgLlamadasVentas)

        'limpio el grid POSVENTA y vuelvo a llenarlo
        mfgLLamadasPosventas.Clear()
        mfgLLamadasPosventas.Rows = 1
        TitulosGllamPV(mfgLLamadasPosventas)
        LeerBDimportadosPV(mfgLLamadasPosventas)

        'Poniendo el valor del pogressbar a 0
        ProgressBar1.Value = 0

    End Sub

    Private Sub btCerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCerrar.Click
        Close()
    End Sub

    Private Sub btAddLlamadas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btAddLlamadas.Click


        'objeto para ejecutar el metodo de importacion de llamadas ATENCION
        Dim importDatosNew As New C_llamadas
        Dim importarDatosVentas As New C_llamadas
        Dim importarDatosPosVta As New C_llamadas


        'INICIO IMPORTACION Y AGREGO NUEVOS DATOS DE LLAMADAS DE ATENCION
        Dim fau_llam As Date
        Dim fec_llam As Date
        Dim nlot_llam As String
        Dim id_tllam As Integer
        Dim id_empr As Integer
        Dim id_au As Integer
        Dim id_ado As Integer
        Dim vaop_salu As Double
        Dim vaop_emp As Double
        Dim vaop_ind As Double
        Dim vaop_disp As Double
        Dim vaop_comp As Double
        Dim vaop_info As Double
        Dim vaop_com As Double
        Dim vaop_cred As Double
        Dim vaop_cie As Double
        Dim tfav_llam As String
        Dim tctra_llam As String
        Dim vato_llam As Double
        Dim idunico_llam As String
        Dim caso_llam As String

        ' fau_llam = ""
        ' fec_llam = ""
        nlot_llam = ""
        id_tllam = 0
        id_empr = 0
        id_au = 0
        id_ado = 0
        vaop_salu = 0
        vaop_emp = 0
        vaop_ind = 0
        vaop_disp = 0
        vaop_comp = 0
        vaop_info = 0
        vaop_com = 0
        vaop_cred = 0
        vaop_cie = 0
        tfav_llam = ""
        tctra_llam = ""
        vato_llam = 0
        idunico_llam = ""
        caso_llam = ""

        With mfgLLamadasAtencion
            For fila = 1 To mfgLLamadasAtencion.Rows - 1
                .Row = fila

                mfgLLamadasAtencion.Col = 1
                fau_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 2
                fec_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 3
                nlot_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 4
                id_tllam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 5
                id_empr = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 6
                id_au = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 7
                id_ado = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 8
                vaop_salu = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 9
                vaop_emp = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 10
                vaop_ind = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 11
                vaop_disp = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 12
                vaop_comp = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 13
                vaop_info = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 14
                vaop_com = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 15
                vaop_cred = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 16
                vaop_cie = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 17
                tfav_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 18
                tctra_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 19
                vato_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 20
                idunico_llam = mfgLLamadasAtencion.Text
                mfgLLamadasAtencion.Col = 21
                caso_llam = mfgLLamadasAtencion.Text

                'ejecuto metodo de importacion de llamadas y paso de parametros los datos obtenidos del grid de importacion
                importDatosNew.importarLLamada(fau_llam, fec_llam, nlot_llam, id_tllam, id_empr, id_au, id_ado, vaop_salu, vaop_emp, vaop_ind, vaop_disp, vaop_comp, vaop_info, vaop_com, vaop_cred, vaop_cie, tfav_llam, tctra_llam, vato_llam, idunico_llam, caso_llam)
                ' mfgLLamadas.RemoveItem(mfgLLamadas.RowSel)
                '.SelectionMode = MSFlexGridLib.SelectionModeSettings.flexSelectionByRow
                '.BackColor = Color.YellowGreen

                'incremento por fila el progressbar
                ProgressBar1.Increment(fila)
            Next
        End With

        'INICIO IMPORTACION Y AGREGO NUEVOS DATOS DE LLAMADAS DE VENTAS
        Dim id_llamV As String
        Dim fau_llamV As Date
        Dim fec_llamV As Date
        Dim nlot_llamV As String
        Dim id_tllamV As Integer
        Dim id_emprV As Integer
        Dim id_auV As Integer
        Dim id_adoV As Integer
        Dim vaop_saluV As Double
        Dim vaop_empV As Double
        Dim vaop_indV As Double
        Dim vaop_manV As Double
        Dim vaop_entV As Double
        Dim vaop_speV As Double
        Dim vaop_preV As Double
        Dim vaop_mecV As Double
        Dim vaop_pideV As Double
        Dim tfav_llamV As String
        Dim tctra_llamV As String
        Dim vato_llamV As Double
        Dim idunico_llamV As String
        Dim caso_llamV As String

        id_llamV = 0
        ' fau_llamV = ""
        ' fec_llamV = ""
        nlot_llamV = ""
        id_tllamV = 0
        id_emprV = 0
        id_auV = 0
        id_adoV = 0
        vaop_saluV = 0
        vaop_empV = 0
        vaop_indV = 0
        vaop_manV = 0
        vaop_entV = 0
        vaop_speV = 0
        vaop_preV = 0
        vaop_mecV = 0
        vaop_pideV = 0
        tfav_llamV = ""
        tctra_llamV = ""
        vato_llamV = 0
        idunico_llamV = ""
        caso_llamV = ""

        With mfgLlamadasVentas
            For fila = 1 To mfgLlamadasVentas.Rows - 1
                .Row = fila

                mfgLlamadasVentas.Col = 1
                fau_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 2
                fec_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 3
                nlot_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 4
                id_tllamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 5
                id_emprV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 6
                id_adoV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 7
                id_adoV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 8
                vaop_saluV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 9
                vaop_empV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 10
                vaop_indV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 11
                vaop_manV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 12
                vaop_entV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 13
                vaop_speV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 14
                vaop_preV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 15
                vaop_mecV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 16
                vaop_pideV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 17
                tfav_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 18
                tctra_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 19
                vato_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 20
                idunico_llamV = mfgLlamadasVentas.Text
                mfgLlamadasVentas.Col = 21
                caso_llamV = mfgLlamadasVentas.Text

                'ejecuto metodo de importacion de llamadas y paso de parametros los datos obtenidos del grid de importacion
                importDatosNew.importarLLamadaV(fau_llamV, fec_llamV, nlot_llamV, id_tllamV, id_emprV, id_auV, id_adoV, vaop_saluV, vaop_empV, vaop_indV, vaop_manV, vaop_entV, vaop_speV, vaop_preV, vaop_mecV, vaop_pideV, tfav_llamV, tctra_llamV, vato_llamV, idunico_llamV, caso_llamV)
                'incremento por fila el progressbar
                ProgressBar1.Increment(fila)
            Next
        End With

        'INICIO IMPORTACION Y AGREGO NUEVOS DATOS DE LLAMADAS DE POSVENTAS
        Dim id_llamPV As String
        Dim fau_llamPV As Date
        Dim fec_llamPV As Date
        Dim nlot_llamPV As String
        Dim id_tllamPV As Integer
        Dim id_emprPV As Integer
        Dim id_auPV As Integer
        Dim id_adoPV As Integer
        Dim vaop_saluPV As Double
        Dim vaop_empPV As Double
        Dim vaop_escPV As Double
        Dim vaop_indPV As Double
        Dim vaop_dispPV As Double
        Dim vaop_prePV As Double
        Dim vaop_comPV As Double
        Dim vaop_ciePV As Double
        Dim tfav_llamPV As String
        Dim tctra_llamPV As String
        Dim vato_llamPV As Double
        Dim idunico_llamPV As String
        Dim caso_llamPV As String

        id_llamPV = 0
        ' fau_llamPV = ""
        ' fec_llamPV = ""
        nlot_llamPV = ""
        id_tllamPV = 0
        id_emprPV = 0
        id_auPV = 0
        id_adoPV = 0
        vaop_saluPV = 0
        vaop_empPV = 0
        vaop_escPV = 0
        vaop_indPV = 0
        vaop_dispPV = 0
        vaop_prePV = 0
        vaop_comPV = 0
        vaop_ciePV = 0
        tfav_llamPV = ""
        tctra_llamPV = ""
        vato_llamPV = 0
        idunico_llamPV = ""
        caso_llamPV = ""

        With mfgLLamadasPosventas
            For fila = 1 To mfgLLamadasPosventas.Rows - 1
                .Row = fila

                mfgLLamadasPosventas.Col = 1
                fau_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 2
                fec_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 3
                nlot_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 4
                id_tllamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 5
                id_emprPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 6
                id_adoPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 7
                id_adoPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 8
                vaop_saluPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 9
                vaop_empPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 10
                vaop_escPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 11
                vaop_indPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 12
                vaop_dispPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 13
                vaop_prePV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 14
                vaop_comPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 15
                vaop_ciePV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 16
                'vaop_pidePV = mfgLLamadasPosventas.Text
                'mfgLLamadasPosventas.Col = 17
                tfav_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 17
                tctra_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 18
                vato_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 19
                idunico_llamPV = mfgLLamadasPosventas.Text
                mfgLLamadasPosventas.Col = 20
                caso_llamPV = mfgLLamadasPosventas.Text

                'ejecuto metodo de importacion de llamadas y paso de parametros los datos obtenidos del grid de importacion
                importDatosNew.importarLLamadaPVta(fau_llamPV, fec_llamPV, nlot_llamPV, id_tllamPV, id_emprPV, id_auPV, id_adoPV, vaop_saluPV, vaop_empPV, vaop_escPV, vaop_indPV, vaop_dispPV, vaop_prePV, vaop_comPV, vaop_ciePV, tfav_llamPV, tctra_llamPV, vato_llamPV, idunico_llamPV, caso_llamPV)
                'incremento por fila el progressbar
                ProgressBar1.Increment(fila)
            Next
        End With

        'FIN DE LA INSERCCION DE DATOS IMPORTADOS, SE MUESTRA EL PROGRESSBAR
        ProgressBar1.Value = 100
        MsgBox("Auditoria Importada con Éxito", MsgBoxStyle.Information, "Auditoria")
        cadenaConexBD.Close()
        Me.Close()
    End Sub

End Class